import request from "../utils/requestUtil.js";
import qs from "qs"


/**
 * 根据标签搜索用户
 * @param tags  标签列表
 * @returns
 */
export async function getUserByTagList(tags) {
    return await request.get('/api/user/selectByTags', {
            params: {tagNameList: tags},
            paramsSerializer: params => {
                return qs.stringify(params, {indices: false})
            }
        },
    )
}

//登录接口
export async function loginApi(account, password) {
    return await request.post('/api/login', {}, {
        params: {
            userAccount: account,
            userPassword: password
        }
    })
}


/**
 * 分页查询
 * @param pageNum  页数
 * @param pageSize  每页条数
 */
export async function recommendApi(pageNum, pageSize) {
    return await request.get('/api/user/recommend', {
        params: {
            pageNum: pageNum,
            pageSize: pageSize
        }
    })
}


/**
 *  更新用户信息
 * @param user  用户
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export async function updateUserInfoApi(user) {
    return await request.post('/api/user/updateUserInfo', user)
}

/**
 *  查询用户信息
 * @param userId    用户id
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export async function getUserByIdApi(userId) {
    return request.get('/api/user/getUserInfo', {
        params: {
            userId: userId
        }
    })
}








